// 实现这个项目的构建任务

const { src, dest, parallel, series } = require("gulp");
// const sass = require("gulp-sass");
const swig = require("gulp-swig");
const imageMin = require("gulp-imagemin");
const del = require("del");
// const style = () => {
//   return src("./src/assets/styles/*.scss", { base: "src" })
//     .pipe(sass({ outputStyle: "expanded" }))
//     .pipe(dest("dist"));
// };

const clean = () => {
  return del["dist"];
};
const script = () => {
  return src("./src/assets/scripts/*.js", { base: "src" })
    .pipe(babel({ presets: ["@babel/preset-env"] }))
    .pipe(dest("dist"));
};

const page = () => {
  return src("./src/*.html", { base: "src" }).pipe(swig()).pipe(dest("dist"));
};

const image = () => {
  return src("./src/assets/images/**", { base: "src" })
    .pipe(imageMin())
    .pipe(dest("dist"));
};

const font = () => {
  return src("./src/assets/fonts/**", { base: "src" })
    .pipe(imageMin())
    .pipe(dest("dist"));
};

const extra = () => {
  return src("./public/**", { base: "public" }).pipe().pipe(dest("dist"));
};

const compile = parallel(script, page, font, image);

const build = series(clean, parallel(compile, extra));
module.exports = {
  compile,
  build,
};
